home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Diamond Collection / The Diamond Collection (Software Vault)(Digital Impact).ISO / cdr48 / tsbat146.zip / DOSTRICK.TXT < prev    next >
Text File  |  1995-01-30  |  10KB  |  263 lines

  1. Assorted MS-DOS Tricks                               Mon 30-Jan-95
  2. ======================
  3.                                                All rights reserved
  4.                              Copyright (c) 1994-1995 by Timo Salmi
  5.  
  6. ..................................................................
  7. Prof. Timo Salmi      Co-moderator of comp.archives.msdos.announce
  8. Moderating at garbo.uwasa.fi anonymous FTP archives  193.166.120.5
  9. Faculty of Accounting & Industrial Management; University of Vaasa
  10. Internet: ts@uwasa.fi   BBS +(358)-61-3170972; FIN-65101,  Finland
  11. ..................................................................
  12.  
  13.   ┌───────────────────────────────────────────────────────────┐
  14.   │ This file belongs to TSBAT*.ZIP. Please do not distribute │
  15.   │ this dostrick.txt file separately! If you see this file   │
  16.   │ alone on a BBS, please alert the SysOp immediately.       │
  17.   └───────────────────────────────────────────────────────────┘
  18.  
  19. You are free to quote brief passages from this file provided you
  20. clearly indicate the source with a proper acknowledgment.
  21.  
  22. Comments and corrections are solicited. But if you wish to have
  23. individual MS-DOS usage consultation, please rather post your
  24. question to a UseNet newsgroup like comp.os.msdos.misc. It is much
  25. more efficient than asking me by email. I'd like to help, but I am
  26. very pressed for time. I prefer to pick the questions I answer from
  27. the Usenet news. Thus I can answer publicly at one go if I happen to
  28. have an answer. Besides, newsgroups have a number of readers who
  29. might know a better or an alternative answer. Don't be discouraged,
  30. though, if you get a reply like this from me. I am always glad to
  31. hear from fellow MS-DOS users.
  32.  
  33.  
  34. INDEX
  35. =====
  36.  
  37. 1) Disabling MS-DOS commands
  38. 2) Simulating disk partitioning
  39. 3) A config.sys and autoexec.bat example
  40. 4) Stepping through config.sys and autoexec.bat command by command
  41. 5) Getting rid of "Insert diskette for drive B:"
  42. 6) Conditional deleting of files
  43. 7) Selected Doskey macro examples
  44.  
  45.  
  46. 1. Disabling MS-DOS commands
  47. ===========================
  48.  
  49. You may wish to disable certain MS-DOS commands for security reasons
  50. to prevent them from being used either accidentally or deliberately.
  51. If you have a command line editor, like doskey, then the disabling
  52. is rather straightforward.  All you have to do is to create a macro
  53. with the same name as the MS-DOS command. Consider the following
  54. examples. The first example disables the internal MS-DOS date
  55. command so that the date on your system cannot be changed.
  56.   doskey date=rem date has been disabled
  57. The second example disables the format command.
  58.   doskey format=rem format has been disabled
  59. Note that since format is an external command, that is it is a
  60. program on your disk, not a command in your command.com command
  61. interpreter, you can still invoke it by giving the explicit path to
  62. it like
  63.   c:\dos\format
  64. In fact, since it will be at path, a drive letter will suffice. Of
  65. course it is very easy to get rid of these redefinitions. In using
  66. doskey, you only have to press alt+F10 to clear the macros.
  67.  
  68. If you use some other command line editor than doskey then the
  69. commands are naturally slightly different.  For example were you to
  70. use CED (garbo.uwasa.fi:/pc/cmdutil/ced10da.zip) the commands would
  71. be
  72.   ced syn date echo date has been disabled
  73. Restoring the date command would be
  74.   ced clear syn date
  75.  
  76.  
  77. 2. Simulating disk partitioning
  78. ===============================
  79.  
  80. Since I have more than one PC at my disposal, I have noticed that it
  81. is very useful to have some common standard on them including
  82. similar disk names. For example I always assume that R: is my
  83. ramdisk. Also I usually have my hard disk partitioned so that I have
  84. a fairly fixed usage for C: D: E: and F:. One of the PCs is an ICL
  85. laptop, with a 120Mb disk all on C: with no partitioning. below is
  86. what I have in my autoexec.bat to have the ram disk reference the
  87. way I want and to simulate the disk partitioning. Note the
  88. importance of the order of the substitute commands because of the
  89. double usage of D, since that is where the ram disk _originally_
  90. resides on my ICL configuration.
  91.   c:\dos\subst r: d:\
  92.   c:\dos\subst d: c:\d
  93.   c:\dos\subst e: c:\e
  94.   c:\dos\subst f: c:\f
  95.  
  96.  
  97. 3. A config.sys and autoexec.bat example
  98. ========================================
  99.  
  100. There always is something to learn from looking at the other users'
  101. config.sys and autoexec.bat files. Here are mine from my office 486
  102. with MS-DOS 5.0.  I have added some comments for you.
  103.  
  104. DEVICE=C:\DOS\SETVER.EXE
  105. DEVICE=C:\DOS\HIMEM.SYS
  106. DOS=UMB
  107. device=c:\dos\emm386.exe /noems /i=e000-efff /x=d200-d600
  108. dos=high
  109. COUNTRY=032,,C:\DOS\COUNTRY.SYS
  110. FILES=30
  111. rem RamDrive of 7Mb, 128Kb sectorsize, 256 entries, extended memory
  112. devicehigh=c:\dos\ramdrive.sys 7000 128 256 /e
  113. rem ZANSI.SYS is from garbo.uwasa.fi:/pc/screen/zansi12.zip
  114. devicehigh=c:\sys\zansi.sys
  115. rem Define a bigger environment size
  116. shell=c:\command.com /p /e:1024
  117. lastdrive=z
  118.  
  119. @ECHO OFF
  120. rem Description: My normal MsDos 5.0 boot with Scrollit
  121. rem Note below the trick to identify which of my PCs I am currently using:
  122. set pcid_=karvi
  123. rem Yellow text on black background
  124. echo <ESC>[40;33;1m
  125. PATH C:\DOS;c:\tools;e:\arczip
  126. rem DAILY.EXE is from /pc/ts/tsbat46.bat to run a mini-backup
  127. rem call c:\bat\daily c:\tools\pkzip -u d:\root\root c:\*.*
  128. PROMPT $p$g
  129. rem CHKSUM is from /pc/goldies/chksum16.zip
  130. c:\tools\chksum command.com 49024 io.sys 9850 msdos.sys 5750
  131. loadhigh c:\dos\KEYB SU,,C:\DOS\KEYBOARD.SYS
  132. rem The Command line EDitor is from /pc/goldies/ced.zip
  133. loadhigh c:\tools\ced -B384,128,768,128,128 -Fced.cfg
  134. rem The TSR memory management until is from /pc/memutil/tsrcom35.zip
  135. c:\tools\mark scrollit
  136. rem The screen scrollback buffer is from /pc/screen/scrlit18.zip
  137. loadhigh c:\tools\scrollit /n=myname /k=myid 60
  138. rem The Snipper screen capture is from /pc/goldies/snippr24.zip
  139. loadhigh c:\tools\snipper
  140. rem The cut and paste utility is from /pc/pcmagvol/vol11n07.zip
  141. loadhigh c:\tools\dosclip2
  142. rem The CapsLock fix is from /pc/ts/tstsr20.zip
  143. loadhigh c:\tuki\shftcaps
  144. c:\dos\subst r: j:\
  145. mkdir r:\cmand
  146. copy c:\command.com r:\cmand
  147. c:\dos\attrib +r r:\cmand\command.com
  148. set comspec=r:\cmand\command.com
  149. set temp=r:\cmand
  150. c:\dos\mode con: rate=32 delay=1
  151. rem The clock comparison check is from /pc/ts/tsutil40.zip
  152. c:\tools\dtetimal 1994
  153. r:
  154.  
  155.  
  156. 4. Stepping through config.sys and autoexec.bat command by command
  157. ==================================================================
  158.  
  159. MS-DOS 6.0 introduced the possibility of pausing at each line of
  160. config.sys and even selecting if the line is executed. If you press
  161. F8 when your PC is being booted and displays "Starting MS-DOS...",
  162. then "MS-DOS will prompt you to confirm each CONFIG.SYS command". If
  163. you have an earlier MS-DOS version, you can still put pauses in your
  164. config.sys by utilizing
  165.  6333 Jan 23 1993 garbo.uwasa.fi:/pc/sysutil/pausedev.zip
  166.  pausedev.zip PAUSE for config.sys (with TP source) D.Murdoch
  167.  
  168. To step through autoexec.bat you can use the following trick
  169.   @echo off
  170.   set debug_=true
  171.   command1
  172.   if "%debug_%" == "true" pause
  173.   command2
  174.   if "%debug_%" == "true" pause
  175.   command3
  176.   set debug_=
  177.  
  178. If you have MS-DOS 6.0 or later you can use the CHOICE command to
  179. prompt whether you want a command to be executed. If you have an
  180. earlier MS-DOS version you can use "CHOOSE.EXE Ask questions in batch
  181. files" from the garbo.uwasa.fi:/pc/ts/tsutlf14.zip (or ASK.EXE from
  182. /pc/ts/tsbat46.zip). Below is an outline example
  183.  
  184.   @echo off
  185.   set debug_=true
  186.  
  187.   if not "%debug_%" == "true" goto _comm1
  188.   CHOOSE /c:yn /n "Execute command1 [Y/N]? "
  189.   if not errorlevel==3 if errorlevel==2 goto _next2
  190.   :_comm1
  191.   command1
  192.  
  193.   :_next2
  194.   if not "%debug_%" == "true" goto _comm2
  195.   CHOOSE /c:yn /n "Execute command2 [Y/N]? "
  196.   if not errorlevel==3 if errorlevel==2 goto _next3
  197.   :_comm2
  198.   command2
  199.  
  200.   :_next3
  201.   (and so on)
  202.  
  203.   set debug_=
  204.  
  205.  
  206. 5. Getting rid of "Insert diskette for drive B:"
  207. ================================================
  208.  
  209.  Q: On my one-floppy-drive PC how can I get rid of the message
  210. "Insert diskette for drive B: and press any key when ready"?
  211.  
  212.  A: The answer is simple as can be. Put the following command into
  213. your AUTOEXEC.BAT file: "SUBST B: A:\". It makes B: point to the one
  214. floppy drive (A:) you have on your system.
  215.  
  216.  
  217. 6. Conditional deleting of files
  218. ================================
  219.  
  220.  This is an improved adaptation of the tip in the PC Computing
  221. Special Issue, 1001 tips, August 1994, pp. 106-232.
  222.  If you have MS-DOS 5+ you can utilize this simple doskey macro to
  223. move files to a trash directory. First ensure that such a directory
  224. exists and if not, mkdir it.
  225.   doskey del=if exist $1 copy $1 r:\trash$Tif not exist $1 echo
  226.   File $1 not found^G$Tif exist $1 del $1 /p
  227. where all the above is on the SAME line.
  228.  You can precede the command with loadhigh to save conventional
  229. memory. I have r: as ramdisk so the trash directory will
  230. automatically be erased when I turn off the computer, or when it
  231. chooses to crash :-).
  232.  
  233.  
  234. 7. Selected Doskey macro examples
  235. =================================
  236.  
  237. Here is a collection of my useful Doskey macros. They are reasonably
  238. simple. You'll learn by working them out in detail. Be somewhat
  239. careful in experimenting. Make test files to try then on rather than
  240. running them on your existing files.
  241.  
  242. a) To go up one directory level.
  243.  doskey up=if exist ..\nul cd ..
  244.  
  245. b) Move a file to another directory.
  246.  doskey mv=if exist $2\nul copy $1 $2$Tif exist $2\nul del $1 /p
  247.  
  248. c) Prevent accidental formats.
  249.  doskey format=echo Bugger off^G^G^G
  250.  (Tip: to format, give the full path. Usually c:\dos\format)
  251.  
  252. d) Touch a file's date/timestamp, that is make it to be now.
  253.  doskey touch=copy $1 + ,,$Tdir $1
  254.  
  255. e) Search for a file through all drives.
  256.  doskey where=for %f in (c d e f g h) do dir %f:\$1 /s /p /b
  257.  
  258. f) Show current time without changing it
  259.  doskey showtime=echo.$Btime$Techo.$Bdate
  260.  
  261. g) Perform a command, skipping a file (wildcards allowed).
  262.  doskey skip=attrib +h $1$T$2 $3 $4 $5 $6 $7 $8 $9$Tattrib -h $1
  263.